主题
图像文件姿态估计 - YoloPoseFromFile
函数简介
从文件做姿态估计。
接口名称
YoloPoseFromFileDLL 调用
long YoloPoseFromFile(long ola, long modelHandle, string imagePath, double confidence, double iou);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug 对象指针,由 CreateCOLAPlugInterFace 生成。 |
| modelHandle | 长整数型 | 模型句柄,任务类型须与接口一致(Detect/Classify/…) |
| imagePath | 字符串 | 图片文件路径;结果坐标相对整张图左上角 |
| confidence | 双精度 | 置信度阈值 0~1:Score 低于此值的候选在 NMS 前丢弃;越大误检越少、漏检越多,常用 0.25~0.5 |
| iou | 双精度 | NMS 的 IoU 阈值 0~1:两框重叠度(IoU)超过此值则抑制低分框以去重;越小框越少,常用 0.45~0.7 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
auto result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5);
if (result.Success) {
// result.RegionCount 为检测框数量,result.Regions 含坐标与类别
// 完整 JSON 字段见 YOLO 推理结果说明文档
}
// 失败时可查看 result.Errorcsharp
using OLAPlug;
var ola = new OLAPlugServer();
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0)
{
// 模型加载失败,请检查路径与密码
}
var result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5);
if (result.Success)
{
// result.RegionCount 为检测框数量,result.Regions 含坐标与类别
// 完整 JSON 字段见 YOLO 推理结果说明文档
}
// 失败时可查看 result.Errorpython
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
# 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if modelHandle == 0:
# 模型加载失败,请检查路径与密码
pass
result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5)
if result.Success:
# result.RegionCount 为检测框数量,result.Regions 含坐标与类别
# 完整 JSON 字段见 YOLO 推理结果说明文档
pass
# 失败时可查看 result.Errorjava
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5);
if (result.Success) {
// result.RegionCount 为检测框数量,result.Regions 含坐标与类别
// 完整 JSON 字段见 YOLO 推理结果说明文档
}
// 失败时可查看 result.Errorcpp
var ola = com("OlaPlug.OlaSoft")
// 加载加密 YOLO 模型包
var modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5)
if (result.Success) {
// result.RegionCount 为检测框数量,result.Regions 含坐标与类别
// 完整 JSON 字段见 YOLO 推理结果说明文档
}
// 失败时可查看 result.Errorvbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
If modelHandle = 0 Then
' 模型加载失败,请检查路径与密码
End If
result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5)
If result.Success Then
' result.RegionCount 为检测框数量,result.Regions 含坐标与类别
' 完整 JSON 字段见 YOLO 推理结果说明文档
End If
' 失败时可查看 result.Errortext
.局部变量 ola, OLAPlug
ola.创建 ()
' 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel(“models/yolov8n.olam“, “your_password“, 0)
.如果真 (modelHandle = 0)
' 模型加载失败,请检查路径与密码
.如果真结束
result = ola.YoloPoseFromFile(modelHandle, “images/scene.png“, 0.45, 0.5)
.如果真 (result.Success)
' result.RegionCount 为检测框数量,result.Regions 含坐标与类别
' 完整 JSON 字段见 YOLO 推理结果说明文档
.如果真结束
' 失败时可查看 result.Erroraardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 加载加密 YOLO 模型包
var modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5);
if (result.Success) {
// result.RegionCount 为检测框数量,result.Regions 含坐标与类别
// 完整 JSON 字段见 YOLO 推理结果说明文档
}
// 失败时可查看 result.Errortext
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 加载加密 YOLO 模型包
长整数 modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
自动 result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5)
if (result.Success) {
// result.RegionCount 为检测框数量,result.Regions 含坐标与类别
// 完整 JSON 字段见 YOLO 推理结果说明文档
}
// 失败时可查看 result.Errorcpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
auto result = ola.YoloPoseFromFile(modelHandle, "images/scene.png", 0.45, 0.5);
if (result.Success) {
// result.RegionCount 为检测框数量,result.Regions 含坐标与类别
// 完整 JSON 字段见 YOLO 推理结果说明文档
}
// 失败时可查看 result.Error原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
// 加载加密 YOLO 模型包
long modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
long resultJsonPtr = YoloPoseFromFile(instance, modelHandle, "images/scene.png", 0.45, 0.5);
if (resultJsonPtr != 0) {
char resultJson[512] = {0};
GetStringFromPtr(resultJsonPtr, resultJson, sizeof(resultJson));
FreeStringPtr(resultJsonPtr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
// 加载加密 YOLO 模型包
long modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0)
{
// 模型加载失败,请检查路径与密码
}
long resultJsonPtr = YoloPoseFromFile(instance, modelHandle, "images/scene.png", 0.45, 0.5);
if (resultJsonPtr != 0) {
StringBuilder resultJson = new StringBuilder(GetStringSize(resultJsonPtr) + 1);
GetStringFromPtr(resultJsonPtr, resultJson, resultJson.Capacity);
FreeStringPtr(resultJsonPtr);
string resultJsonStr = resultJson.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
# 加载加密 YOLO 模型包
modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0)
if modelHandle == 0:
# 模型加载失败,请检查路径与密码
pass
resultJsonPtr = YoloPoseFromFile(instance, modelHandle, "images/scene.png", 0.45, 0.5)
if resultJsonPtr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(resultJsonPtr, buf, 512)
ola.FreeStringPtr(resultJsonPtr)
resultJson = buf.value.decode("utf-8")返回值
长整数型:PascalCase JSON 推理结果字符串指针;失败时 Success 为 false。
注意事项
- 需要插件已开通 YOLO 模块权限(Reg、Login的FeatureList中包含YOLO特性)。
- 须为 Pose 模型;Region 含 Keypoints 关键点数组。
- 推理入参(confidence、iou、topK、classes 等)详解见 推理输入参数说明。
- 推理结果 JSON 字段说明见 推理结果JSON说明。
- 返回的 JSON 字符串须调用 FreeStringPtr 释放。
本接口关键参数
| 参数 | 作用摘要 |
|---|---|
confidence | 人体检测框置信度阈值 |
iou | 检测框 NMS 的 IoU 阈值 |
另输出 Keypoints。详见 推理输入参数说明。
